﻿using FMusicReload.Utils;
using HandyControl.Themes;
using HTBInject.Utils;
using System;
using System.Windows;
using System.Windows.Media;

namespace FMusicReload.Views
{
    public partial class Setting 
    {

        public delegate void Switcher(object obj);
        public static event Switcher ThemeSwitch;

        private LogHelper lh = new LogHelper("SettingView");
        public Setting()
        {
            InitializeComponent();
            lh.SendLog("Setting View Loaded Done!");
            GC.Collect();

            background1.Background = StaticColorAssets.GetBasicColor();
            background1.BorderBrush = StaticColorAssets.GetBorderColor();

            enable1.IsChecked = StaticColorAssets.DarkMode;

            enable1.Click += (S, e) =>
             {
                 if((bool)enable1.IsChecked)
                 {
                     StaticColorAssets.black = new SolidColorBrush(Color.FromRgb(255, 255, 255));
                     StaticColorAssets.DarkMode = true;
                     background1.Background = StaticColorAssets.GetBasicColor();
                     background1.BorderBrush = StaticColorAssets.GetBorderColor();
                     ThemeSwitch(StaticColorAssets.DarkMode);
                     ThemeResources theme = (ThemeResources)Application.Current.Resources.MergedDictionaries[0];
                     theme.MergedDictionaries[0].Source = new Uri("pack://application:,,,/HandyControl;component/Themes/Basic/Colors/Dark.xaml", UriKind.RelativeOrAbsolute);
                 }else
                 {
                     StaticColorAssets.black = new SolidColorBrush(Color.FromRgb(0, 0, 0));
                     StaticColorAssets.DarkMode = false;
                     background1.Background = StaticColorAssets.GetBasicColor();
                     background1.BorderBrush = StaticColorAssets.GetBorderColor();
                     ThemeSwitch(StaticColorAssets.DarkMode);
                     ThemeResources theme = (ThemeResources)Application.Current.Resources.MergedDictionaries[0];
                     theme.MergedDictionaries[0].Source = new Uri("pack://application:,,,/HandyControl;component/Themes/Basic/Colors/Light.xaml", UriKind.RelativeOrAbsolute);
                 }
             };

            apply.Click += (s, e) =>
            {
                
            };
        }
    }
}
